/******************************************************************************
 * ----------------------------------------------------------------------------
 * ACA ASSIGNMENT 3: Simulation of MOESI cache coherence
 * Name: Shriram Gurumoorthy
 * GTID: 902535405
 * Email: shriram.g@gatech.edu
 *
 * This file has the main function and functions used to simulate
 * the MOESI cache coherence
 * ----------------------------------------------------------------------------
 * ***************************************************************************/

#ifndef __MOESI_H__
#define __MOESI_H__

#include "globals.h"
#include "utils.h"

/* DM cache parameters */
unsigned int DMSize = 16*1024;
unsigned int DMCacheLineSize = 64;
unsigned int DMNumCacheLine;
unsigned int DMIndexBits;
unsigned int DMOffsetBits;

/* SA cache parameters */
unsigned int SASize = 32*1024;
unsigned int SACacheLineSize = 128;
unsigned int SANumCacheLine;
unsigned int SANumber = 2;
unsigned int SAIndexBits;
unsigned int SAOffsetBits;

/* Messages on the bus */
int busRdFlag = FALSE;
int busRdXFlag = FALSE;
int busUpgrFlag = FALSE;

/* Information on which processor is broadcasting */
unsigned int procOnBus = NUM_CORE;

/* Variable used to maintain the time */
int time = 0;

/* Function Prototypes */
void ReadDMCacheHandler(int proc, int addr);
void WriteDMCacheHandler(int proc, int addr);

void BusRdDMCacheHandler();
void BusRdXDMCacheHandler();
void BusUpgrDMCacheHandler();

void HandleBusRd(int proc);
void HandleBusRdX(int proc);
void HandleBusUpgr(int proc);

#endif

